package com.rimi.lzhg.service.impl;

import com.rimi.lzhg.dao.CommentMapper;
import com.rimi.lzhg.entry.Comment;
import com.rimi.lzhg.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public boolean saveComment(Comment comment) {
        if(comment==null){
            return false;
        }
        if(comment.getDate()==null){
            comment.setDate(new Date());
        }
        int insert = commentMapper.insert(comment);
        if (insert>0){
            return true;
        }
        return false;
    }
}
